package com.sanben.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sanben.common.web.domain.Result;
import java.util.List;

import com.sanben.project.entity.ProjectBidding;
import com.sanben.project.data.dto.ProjectBiddingDto;
import com.sanben.project.data.vo.ProjectBiddingVo;
import com.sanben.project.data.req.ProjectBiddingReq;
import com.sanben.project.service.IProjectBiddingService;

/**
 * @author cyh
 * @description: 项目竞标表 控制器
 * @date: 2020-08-11
 */
@RestController
@RequestMapping("projectBidding")
@Api(tags = "项目竞标表相关接口")
public class ProjectBiddingController {

    @Autowired
	private IProjectBiddingService projectBiddingService;

	@GetMapping("/page")
	@ApiOperation(value = "分页", notes = "传入projectBidding")
	public Result<IPage<ProjectBiddingVo>> page(ProjectBiddingReq req) {
		IPage<ProjectBiddingVo> pages = projectBiddingService.page(req);
		return Result.data(pages);
	}

	@GetMapping("/list")
	@ApiOperation(value = "不分页")
	public Result<List<ProjectBidding>> list() {
		List<ProjectBidding> list = projectBiddingService.lists();
		return Result.data(list);
	}

	@GetMapping("/{id}")
	@ApiOperation(value = "详情", notes = "传入id")
	public Result<ProjectBidding> detail(@PathVariable Integer id) {
	    ProjectBidding detail = projectBiddingService.detail(id);
		return Result.data(detail);
	}

	@PostMapping
	@ApiOperation(value = "新增", notes = "传入projectBidding")
	public Result save(@RequestBody ProjectBiddingDto dto) {
		return Result.data(projectBiddingService.save(dto));
	}

	@PutMapping
	@ApiOperation(value = "修改", notes = "传入projectBidding")
	public Result update(@RequestBody ProjectBiddingDto dto) {
		return Result.data(projectBiddingService.updateById(dto));
	}

	@DeleteMapping("/{ids}")
	@ApiOperation(value = "逻辑删除", notes = "传入ids")
	public Result remove(@PathVariable List<Integer> ids) {
		return Result.data(projectBiddingService.deleteLogic(ids));
	}

}
